﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace WikiMarkupConverter
{
    internal static class LogFileHelper
    {
        private const string LogFilePath = "./convert.log";
        private static readonly List<string> Messages = new List<string>();

        internal static void AddMessageToLog(string message)
        {
            Messages.Add(string.Format("{0}: {1}", DateTime.Now, message));

        }

        internal static async void WriteLogAsync()
        {
            var writer = File.AppendText(LogFilePath);
            foreach (var message in Messages)
            {
                await writer.WriteLineAsync(message);
            }
            await writer.FlushAsync();
            writer.Close();
        }
    }
}
